/*
 * 应用管理
 */

Ext.define('MyApp.view.AppInfoWindow', {
    extend: 'Ext.window.Window',
    title: '新增/修改应用信息',
    width: 500,
    closeAction: 'hide',
    modal: true,
    form: null,
    getForm: function(){
        var me = this;
        if(me.form==null){
            me.form = Ext.widget('form',{
                layout: 'column',
                defaults: {
                    margin: '10 10 5 5',
                    columnWidth: 1,
                    xtype: 'textfield',
                    labelWidth: 80
                },
                items: [{
                	xtype: 'commonappinfoselector',
                    fieldLabel: '应用Id',
                    name: 'appId',
                    allowBlank: false,
                    listeners:{
				         'select': function(combo,records,eOpts){
				         	var formInfo=me.form.getForm();
				         	formInfo.loadRecord(records[0]);
				         }
				    }
                },{
                    fieldLabel: '百度云key',
                    name: 'baiduApiKey',
                    allowBlank: false
                },{
                    fieldLabel: '百度云密钥',
                    name: 'baiduSecretKey',
                    allowBlank: false
                },{
                    fieldLabel: '证书路径',
                    id:'apnsUpload',
                    name: 'apnsUpload',
                    xtype:'filefield',
                    validator: function(value,message){
                                var arr = value.split('.');
                                if(me.isUpdate){
                                	Ext.getCmp("apnsUpload").allowBlank = true;
                                	if(value==""){
                                		return true;
                                	}else{
                                		if(arr[arr.length-1] != 'p12'){
                                			return false;
                                		}else{
                                			return true;
                                		}
                                	}
                                }else{
                                	Ext.getCmp("apnsUpload").allowBlank = false;
                                	if(value==""){
                                			return false;
                                		}else{
                                			if(arr[arr.length-1] != 'p12'){
                                    			return false;
                                    		}else{
                                    			return true;
                                		}
                                	}
                                }
                	            
                  	          },
                },{
                    fieldLabel: '证书密码',
                    name: 'apnsPassword',
                    allowBlank: false
                },{
                    fieldLabel: '应用名称',
                    name: 'appName',
                    allowBlank: false
                },{
                    fieldLabel: '详细信息',
                    name: 'descInfo'
                }],
                buttons: [{
                    text:'保存',
                    handler: function() {
                        var formView = me.getForm(),
                            form = formView.getForm(),
                            record = form.getRecord(),
                            url = './rs/appinfo/addAppInfo',params,
                            message = '新增';
                        if(!form.isValid()){
                            return;
                        }
                        form.updateRecord(record);
                        var params = record.data;
                        if(me.isUpdate){
                        	url = './rs/appinfo/updateAppInfo';
                        	message = '修改';
                        	Ext.Object.merge(params,{
								'id': record.get('id')
							});
                        }
                        form.submit({
                            url : url,
                            waitMsg: '正在保存。。。',
							params: params,
                            success : function(from, action, json) {
                                var appInfoManager = Ext.getCmp('appInfoManager'),
                                    store = appInfoManager.getStore();
                                Ext.ux.Toast.msg("温馨提示", message + "成功");
                                me.close();
                                store.load();
                            },
                            exception : function(from, action, json) {
                                Ext.ux.Toast.msg("温馨提示", json.responseStatus.message);
                            }
                        });
                    }
                }]
            });
        }
        return me.form;
    },
    isUpdate: null,
    bindData: function(record,isUpdate){
        var me = this,formView=me.getForm(),
            form = formView.getForm();
        form.reset();
        form.loadRecord(record);
        me.isUpdate = isUpdate;
        if(!isUpdate){
            form.reset();
        }
    },
    constructor : function(config) {
        var me = this, cfg = Ext.apply({}, config);
        me.items = [me.getForm()]
        me.callParent([ cfg ]);
    }
});

/**
 *  新增/修改mq
 */
Ext.define('MyApp.view.AppMqWindow', {
    extend: 'Ext.window.Window',
    title: '新增/修改消息队列信息',
    width: 400,
    closeAction: 'hide',
    modal: true,
    form: null,
    getForm: function(){
        var me = this;
        if(me.form==null){
            me.form = Ext.widget('form',{
                layout: 'column',
                defaults: {
                    margin: '5 5 5 5',
                    columnWidth: 1,
                    xtype: 'textfield',
                    labelWidth: 80
                },
                items: [{
                	xtype:'fieldset',
                    title: '应用信息',
                    defaultType: 'textfield',
                    columnWidth: 1,
                    layout: 'column',
                    collapsed: false,
                    defaults: {
                        margin: '5 0 5 0'
                    },
                    items: [{
                    	   width:330,
                    	   labelWidth: 73,
	                       fieldLabel: '应用Id',
		                   name: 'appId',
		                   readOnly:true
                    },{
                    	   width:330,
                    	   labelWidth: 73,
                           fieldLabel: '应用名称',
	               		   name: 'appName',
	               		   disabled:true
                    }]
                },{    
                	
                    fieldLabel: '队列名称',
                    name: 'queueName',
                    allowBlank: false
                },{    
                    fieldLabel: 'id',
                    name: 'id',
                    hidden: true
                },DataDictionary.getDataDictionaryCombo('queuePriority',{
                	fieldLabel: '队列优先级',
                	labelWidth: 80,
					name: 'queuePriority',
					allowBlank: false,
					editable: false
				}),DataDictionary.getDataDictionaryCombo('queueType',{
                	fieldLabel: '队列类型',
                	labelWidth: 80,
					name: 'queueType',
					allowBlank: false,
					editable: false
				})],
                buttons: [{
                    text:'保存',
                    handler: function() {
                        var formView = me.getForm(),
                            form = formView.getForm(),params,
                            record = form.getValues(),
                            url = './rs/appMq/addAppMq',
                            message = '新增';
                        if(!form.isValid()){
                            return;
                        }
                        if(me.isUpdate){
                        	url = './rs/appMq/modifyAppMq';
                        	message = '修改';
                        }
                        Ext.Ajax.request({
                            url : url,
                            jsonData: {
                            	"appMq": record
                            },
                            success : function(response, opts) {
                                var appInfoManager = Ext.getCmp('appInfoManager'),
                                    store = appInfoManager.getStore();
                                Ext.ux.Toast.msg("温馨提示", message + "成功");
                                me.close();
                                store.load();
                            },
                            exception : function(response, opts) {
                                var json = Ext.decode(response.responseText);
                                Ext.ux.Toast.msg("温馨提示", json.responseStatus.message);
                            }
                        });
                    }
                }]
            });
        }
        return me.form;
    },
    isUpdate: null,
    bindData: function(record,isUpdate){
        var me = this,formView=me.getForm(),
            form = formView.getForm();
        form.reset();
        form.loadRecord(record);
        me.isUpdate = isUpdate;
        if(isUpdate){
        	form.findField('appName').setValue(record.get('appName'));
        }
    },
    constructor : function(config) {
        var me = this, cfg = Ext.apply({}, config);
        me.items = [me.getForm()]
        me.callParent([ cfg ]);
    }
});

Ext.define('MyApp.view.appInfoManager', {
    extend: 'Ext.panel.Panel',
    id: 'appInfoManager',
    closable: true,
    title: '应用管理',
    queryForm: null,
	getQueryForm: function(){
		var me = this;
		if(me.queryForm==null){
			me.queryForm = Ext.widget('form',{
                layout: 'column',
				defaults: {
					margin: '10 10 10 10',
					xtype: 'textfield'
				},
                items: [{
				    fieldLabel: '应用id',
				    columnWidth: .25,
					labelWidth: 80,
				    name: 'appId'
				},{
				    fieldLabel: '应用名称',
				    columnWidth: .25,
					labelWidth: 80,
				    name: 'appName'
				},{
			        fieldLabel: '创建日期',
			        columnWidth: .5,
					labelWidth: 80,
			        xtype: 'rangedatefield',
			        //起始日期组件的name属性。
			        fromName: 'createStartTime',
			        //终止日期组件的name属性。
			        toName: 'createEndTime'
			    }],
                buttons: [{
					text:'查询',
					handler: function() {
						me.getPagingToolbar().moveFirst();
					}
				},'-',{
					text:'重置',
					handler: function() {
						me.getQueryForm().getForm().reset();
					}
				},'->']
            });
		}
		return this.queryForm;
	},
	store: null,
	getStore: function(){
		var me = this;
		if(me.store==null){
			me.store = Ext.create('MyApp.store.AppInfoStore',{
				autoLoad: true,
				listeners: {
					beforeload : function(store, operation, eOpts) {
						var queryForm = me.getQueryForm();
						if (queryForm != null) {
							var values = queryForm.getValues();
							Ext.apply(operation, {
								params: {
									'createStartTime': values.createStartTime,
									'createEndTime': values.createEndTime,
									'appId': Ext.String.trim(values.appId),
									'appNameLike': Ext.String.trim(values.appName)
								}
							});	
						}
					}
				}
			});
		}
		return me.store;
	},
	pagingToolbar: null,
	getPagingToolbar: function(){
		var me = this;
		if(me.pagingToolbar==null){
			me.pagingToolbar = Ext.widget('pagingtoolbar',{
				store: me.getStore(),
				dock: 'bottom',
				displayInfo: true
			});
		}
		return me.pagingToolbar;
	},
    toolbar: null,
    getToolbar: function(){
        var me = this;
        if(Ext.isEmpty(me.toolbar)){
            me.toolbar = Ext.widget('toolbar',{
                dock: 'top',
                items: [{
                    itemId: 'addButton',
                    text: '注册',
                    listeners: {
                        click: {
                            fn: me.addAppInfo,
                            scope: me
                        }
                    }
                },'-',{
					xtype: 'button',
					itemId: 'editButton',
					text: '编辑',
					listeners: {
						click: {
							fn: me.modifyAppInfo,
							scope: me
						}
					}
				},'-',{
					xtype: 'button',
					itemId: 'enableButton',
					text: '启用',
					listeners: {
						click: {
							fn: me.enableAppInfo,
							scope: me
						}
					}
				},'-',{
					xtype: 'button',
					itemId: 'disableButton',
					text: '禁用',
					listeners: {
						click: {
							fn: me.disableAppInfo,
							scope: me
						}
					}
//				},'-',{
//                    xtype: 'button',
//                    itemId: 'resetKeyButton',
//                    text: '重置密钥',
//                    listeners: {
//                        click: {
//                            fn: me.resetAppKey,
//                            scope: me
//                        }
//                   }
                }]
            });
        }
        return me.toolbar;
    },
    appInfoWindow: null,
    getAppInfoWindow: function(){
        if(this.appInfoWindow == null){
            this.appInfoWindow = new MyApp.view.AppInfoWindow();
        }
        return this.appInfoWindow;
    },
    // 新增应用信息
    addAppInfo: function(button, e, eOpts) {
        var window = this.getAppInfoWindow();
        window.bindData(Ext.create('MyApp.model.AppInfoModel'), false);
        window.show();
    },
    // 编辑应用
    modifyAppInfo: function(button, e, eOpts) {
		var grid = this.getAppInfoGrid(),
			selModel = grid.getSelectionModel(),
			selRecords = selModel.getSelection(),
			window = this.getAppInfoWindow();
    	if(selRecords == null||selRecords.length<=0){
    		Ext.ux.Toast.msg("温馨提示", "请先选择要编辑的应用");
    		return;
    	}
    	window.bindData(selRecords[0],true);
		window.show();
    },
    // 禁用应用
    disableAppInfo: function(button, e, eOpts) {
    	var grid = this.getAppInfoGrid(),
			selModel = grid.getSelectionModel(),
			selRecords = selModel.getSelection();
    	if(selRecords == null||selRecords.length<=0){
    		Ext.ux.Toast.msg("温馨提示", "请先选择要禁用的应用");
    		return;
    	}
		var record = selRecords[0];
		if(record.get('isDeleted')){
			Ext.ux.Toast.msg("温馨提示", "该应用已经禁用！");
			return;
		}
    	Ext.MessageBox.confirm('温馨提示', '确定禁用该应用吗？', function(btn){
			if(btn == 'yes'){
				Ext.Ajax.request({
					url : './rs/appinfo/disableAppInfo',
					jsonData: {'id': record.get('id')},
					success : function(response, opts) {
						Ext.ux.Toast.msg("温馨提示", "禁用成功！");
						grid.getStore().load();
						grid.getSelectionModel().deselectAll();
					},
					exception : function(response, opts) {
						var json = Ext.decode(response.responseText);
						Ext.ux.Toast.msg("温馨提示", json.responseStatus.message);
					}
				});
    		}else{
    			return;
    		}
		});
    },
	// 启用应用
    enableAppInfo: function(button, e, eOpts) {
    	var grid = this.getAppInfoGrid(),
			selModel = grid.getSelectionModel(),
			selRecords = selModel.getSelection();
    	if(selRecords == null||selRecords.length<=0){
    		Ext.ux.Toast.msg("温馨提示", "请先选择要启用的应用");
    		return;
    	}
		var record = selRecords[0];
		if(!record.get('isDeleted')){
			Ext.ux.Toast.msg("温馨提示", "该应用已经启用！");
			return;
		}
    	Ext.MessageBox.confirm('温馨提示', '确定启用该应用吗？', function(btn){
			if(btn == 'yes'){
				Ext.Ajax.request({
					url : './rs/appinfo/enableAppInfo',
					jsonData: {'id': record.get('id')},
					success : function(response, opts) {
						Ext.ux.Toast.msg("温馨提示", "启用成功！");
						grid.getStore().load();
						grid.getSelectionModel().deselectAll();
					},
					exception : function(response, opts) {
						var json = Ext.decode(response.responseText);
						Ext.ux.Toast.msg("温馨提示", json.responseStatus.message);
					}
				});
    		}else{
    			return;
    		}
		});
    },
    //重置密钥
    resetAppKey:function(){
    	var grid = this.getAppInfoGrid(),
			selModel = grid.getSelectionModel(),
			selRecords = selModel.getSelection();
		if(selRecords == null||selRecords.length<=0){
			Ext.ux.Toast.msg("温馨提示", "请先选择要重置密钥的应用");
			return;
		}
		var record = selRecords[0];
		Ext.MessageBox.confirm('温馨提示', '确定重置该应用的密钥吗？', function(btn){
			if(btn == 'yes'){
				Ext.Ajax.request({
					url : './rs/appinfo/resetAppKey',
					jsonData: {'id': record.get('id')},
					success : function(response, opts) {
						Ext.ux.Toast.msg("温馨提示", "重置密钥成功！");
						grid.getStore().load();
						grid.getSelectionModel().deselectAll();
					},
					exception : function(response, opts) {
						var json = Ext.decode(response.responseText);
						Ext.ux.Toast.msg("温馨提示", json.responseStatus.message);
					}
				});
			}else{
				return;
			}
		});
    },
	appInfoGrid: null,
	getAppInfoGrid: function(){
		var me = this;
		if(Ext.isEmpty(me.appInfoGrid)){
			me.appInfoGrid = Ext.widget('gridpanel',{
                columnLines: false,
                store: me.getStore(),
                plugins: [{
                    ptype: 'hn658rowexpander',
                    header: true,
                    rowsExpander: true,
                    rowBodyElement : 'MyApp.view.AppInfoDetailPanel'
                }],
				columns: [{
					xtype: 'rownumberer'
				},{
					dataIndex: 'isDeleted',
					text: '是否启用',
					flex: 0.8,
					align: 'center',
					renderer: function(value, metaData, record, rowIndex, colIndex, store, view) {
		            	return CommonFunction.rendererEnable(value);
		            }
				},{
                    dataIndex: 'appId',
                    sortable: false,
                    flex: 2,
                    xtype: 'ellipsiscolumn',
                    align: 'center',
                    text: '应用id'
                },{
                    dataIndex: 'appName',
                    sortable: false,
                    flex: 1,
                    xtype: 'ellipsiscolumn',
                    align: 'center',
                    text: '应用名称'
                },{
                    dataIndex: 'baiduApiKey',
                    sortable: false,
                    flex: 1,
                    xtype: 'ellipsiscolumn',
                    align: 'center',
                    text: '百度云Key'
                },{
                    dataIndex: 'baiduSecretKey',
                    sortable: false,
                    flex: 1,
                    xtype: 'ellipsiscolumn',
                    align: 'center',
                    text: '百度云密钥'
                },{
                    dataIndex: 'apnsPath',
                    flex: 2,
                    xtype: 'ellipsiscolumn',
                    align: 'center',
                    text: '证书路径'
                },{
                    dataIndex: 'apnsPassword',
                    sortable: false,
                    flex: 1,
                    xtype: 'ellipsiscolumn',
                    align: 'center',
                    text: '证书密码'
                },{
					xtype: 'datecolumn',
					format:'Y-m-d H:i:s',
					dataIndex: 'createTime',
					align: 'center',
					text: '创建时间',
					flex: 1.3
				},{
					xtype: 'datecolumn',
					format:'Y-m-d H:i:s',
					dataIndex: 'lastUpdateTime',
					align: 'center',
					text: '更新时间',
					flex: 1.3
				},{
                	xtype: 'linebreakcolumn',
                    dataIndex: 'descInfo',
                    sortable: false,
                    flex: 1.5,
                    text: '备注'
                }],
				dockedItems: [me.getPagingToolbar(),me.getToolbar()],
				selModel: Ext.create('Ext.selection.CheckboxModel', {
					allowDeselect: true,
					mode: 'SINGLE'
				})
			});
		}
		return me.appInfoGrid;
	},
    initComponent: function() {
        var me = this;
        Ext.applyIf(me, {
            items: [me.getQueryForm(),me.getAppInfoGrid()]
        });
        me.callParent(arguments);
    }
});


Ext.define('MyApp.view.appMQGrid', {
    extend: 'Ext.grid.Panel',
    header: false,
    height:	250,
    columnLines: true,
	constructor: function(config){
		var me = this, cfg = Ext.apply({}, config);
		me.selModel = Ext.create('Ext.selection.CheckboxModel', {
			allowDeselect: true,
			mode: 'SINGLE'
		});
		me.columns = [{
			xtype: 'rownumberer'
	    },{
	    	dataIndex: 'appId',
	    	text: '应用ID',
			align: 'center',
			sortable: false,
	        flex: 1
		},{
	        dataIndex: 'queueNumber',
	        sortable: false,	
	        flex: 1,
	        align: 'center',
	        text: '队列编号'
	    },{
	        dataIndex: 'queueName',
	        sortable: false,
	        flex: 1,
	        align: 'center',
	        text: '队列名称'
	    },{
	        dataIndex: 'queuePriority',
	        sortable: false,
	        flex: 1.5,
	        renderer: function(value, metaData, record, rowIndex, colIndex, store, view) {
		        	return DataDictionary.rendererSubmitToDisplay(value, 'queuePriority');
		    },
	        align: 'center',
	        text: '优先级'
	    },{
	        dataIndex: 'queueType',
	        sortable: false,
	        flex: 1.5,
	        renderer: function(value, metaData, record, rowIndex, colIndex, store, view) {
		        	return DataDictionary.rendererSubmitToDisplay(value, 'queueType');
		    },
	        align: 'center',
	        text: '队列类型'
	    },{
	        dataIndex: 'isDeleted',
	        sortable: false,
	        flex: 1.5,
	        align: 'center',
	        renderer: function(value, metaData, record, rowIndex, colIndex, store, view) {
		            	return CommonFunction.rendererEnable(value);
		    },
	        text: '是否启用'
		},{
			xtype: 'datecolumn',
			format:'Y-m-d H:i:s',
			dataIndex: 'createTime',
			align: 'center',
			sortable: false,
			text: '创建时间',
			flex: 2
		},{
			xtype: 'datecolumn',
			format:'Y-m-d H:i:s',
			dataIndex: 'lastUpdateTime',
			align: 'center',
			sortable: false,
			text: '最后更新时间',
			flex: 2
		},{
			xtype: 'datecolumn',
			format:'Y-m-d H:i:s',
			dataIndex: 'endTime',
			align: 'center',
			sortable: false,
			text: '删除时间',
			flex: 2
		}];
		me.callParent([cfg]);
	}
});

//应用MQ详情
Ext.define('MyApp.view.AppInfoDetailPanel', {
    extend: 'Ext.panel.Panel',
    title: '应用消息队列',
	padding: '5 30 5 30',
	grid: null,
	getMqGrid: function(){
		var me = this;
		if(me.grid==null){
			me.grid = Ext.create('MyApp.view.appMQGrid',{
				store: me.getStore(),
				dockedItems: [me.getPagingToolbar(),me.getToolbar()]
			});
		}
		return me.grid;
	},
	toolbar: null,
	getToolbar: function(){
		var me = this;
		if(Ext.isEmpty(me.toolbar)){
			me.toolbar = Ext.widget('toolbar',{
				dock: 'top',
				 items: [{
                    itemId: 'addButton',
                    text: '添加',
                    listeners: {
                        click: {
                            fn: me.addAppMq,
                            scope: me
                        }
                    }
                },'-',{
					xtype: 'button',
					itemId: 'editButton',
					text: '修改',
					listeners: {
						click: {
							fn: me.modifyAppMq,
							scope: me
						}
					}
				},'-',{
					xtype: 'button',
					itemId: 'enableButton',
					text: '启用',
					listeners: {
						click: {
							fn: me.enableAppMq,
							scope: me
						}
					}
				},'-',{
					xtype: 'button',
					itemId: 'disableButton',
					text: '禁用',
					listeners: {
						click: {
							fn: me.disableAppMq,
							scope: me
						}
					}
				}]
			});
		}
		return me.toolbar;
	},
	appMqWindow: null,
    getAppMqWindow: function(){
        if(this.appMqWindow == null){
            this.appMqWindow = new MyApp.view.AppMqWindow();
        }
        return this.appMqWindow;
    },
    // 新增Mq
    addAppMq: function(button, e, eOpts) {
        var window = this.getAppMqWindow(),
        model=Ext.create('MyApp.model.AppInfoModel');
        model.set('appId',this.appId);
        model.set('appName',this.appName);
        window.bindData(model, false);
        window.show();
    },
    // 编辑Mq
    modifyAppMq: function(button, e, eOpts) {
		var grid = this.getMqGrid(),
			selModel = grid.getSelectionModel(),
			selRecords = selModel.getSelection(),
			window = this.getAppMqWindow();
    	if(selRecords == null||selRecords.length<=0){
    		Ext.ux.Toast.msg("温馨提示", "请先选择要编辑的队列");
    		return;
    	}
    	selRecords[0].set('appName',this.appName);
    	window.bindData(selRecords[0],true);
		window.show();
    },
    // 禁用Mq
    disableAppMq: function(button, e, eOpts) {
    	var grid = this.getMqGrid(),
			selModel = grid.getSelectionModel(),
			selRecords = selModel.getSelection();
    	if(selRecords == null||selRecords.length<=0){
    		Ext.ux.Toast.msg("温馨提示", "请先选择要禁用的队列");
    		return;
    	}
		var record = selRecords[0];
		if(record.get('isDeleted')){
			Ext.ux.Toast.msg("温馨提示", "该队列已经禁用！");
			return;
		}
    	Ext.MessageBox.confirm('温馨提示', '确定禁用该队列吗？', function(btn){
			if(btn == 'yes'){
				Ext.Ajax.request({
					url : './rs/appMq/disableAppMq',
					jsonData: {'id': record.get('id')},
					success : function(response, opts) {
						Ext.ux.Toast.msg("温馨提示", "禁用成功！");
						grid.getStore().load();
						grid.getSelectionModel().deselectAll();
					},
					exception : function(response, opts) {
						var json = Ext.decode(response.responseText);
						Ext.ux.Toast.msg("温馨提示", json.responseStatus.message);
					}
				});
    		}else{
    			return;
    		}
		});
    },
	// 启用Mq
    enableAppMq: function(button, e, eOpts) {
    	var grid = this.getMqGrid(),
			selModel = grid.getSelectionModel(),
			selRecords = selModel.getSelection();
    	if(selRecords == null||selRecords.length<=0){
    		Ext.ux.Toast.msg("温馨提示", "请先选择要启用的队列");
    		return;
    	}
		var record = selRecords[0];
		if(!record.get('isDeleted')){
			Ext.ux.Toast.msg("温馨提示", "该队列已经启用！");
			return;
		}
    	Ext.MessageBox.confirm('温馨提示', '确定启用该队列吗？', function(btn){
			if(btn == 'yes'){
				Ext.Ajax.request({
					url : './rs/appMq/enableAppMq',
					jsonData: {'id': record.get('id')},
					success : function(response, opts) {
						Ext.ux.Toast.msg("温馨提示", "启用成功！");
						grid.getStore().load();
						grid.getSelectionModel().deselectAll();
					},
					exception : function(response, opts) {
						var json = Ext.decode(response.responseText);
						Ext.ux.Toast.msg("温馨提示", json.responseStatus.message);
					}
				});
    		}else{
    			return;
    		}
		});
    },
	appId: null,
	appName:null,
	store: null,
	getStore: function(){
		var me = this;
		if(me.store==null){
			me.store = Ext.create('MyApp.store.AppMqStore',{
				pageSize: 10,
				autoLoad: true,
				listeners: {
					beforeload : function(store, operation, eOpts) {
						Ext.apply(operation, {
							params: {
								'appId': me.appId
							}
						});
					}
				}
			});
		}
		return me.store;
	},
	pagingToolbar: null,
	getPagingToolbar: function(){
		var me = this;
		if(me.pagingToolbar==null){
			me.pagingToolbar = Ext.widget('pagingtoolbar',{
				store: me.getStore(),
				dock: 'bottom',
				displayInfo: true
			});
		}
		return me.pagingToolbar;
	},
	bindData: function(record){
		var me = this,
			grid = me.getMqGrid();
		me.appId=record.get('appId');
		me.appName=record.get('appName');
		me.getStore();
		grid.store.load();
	},
    initComponent: function() {
        var me = this;
        Ext.applyIf(me, {
            items: [me.getMqGrid()]
        });
        me.callParent(arguments);
    }
});
